home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / tankbatt.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  3KB  |  129 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. unsigned char *tankbatt_bulletsram;
  13. size_t tankbatt_bulletsram_size;
  14.  
  15. /***************************************************************************
  16.  
  17.   Convert the color PROMs into a more useable format.
  18.  
  19. ***************************************************************************/
  20. void tankbatt_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  21. {
  22.     int i;
  23.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  24.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  25.  
  26.     #define RES_1    0xc0 /* this is a guess */
  27.     #define RES_2    0x3f /* this is a guess */
  28.  
  29.     /* Stick black in there */
  30.     *(palette++) = 0;
  31.     *(palette++) = 0;
  32.     *(palette++) = 0;
  33.  
  34.     /* ? Skip the first byte ? */
  35.     color_prom++;
  36.  
  37.     for (i = 1;i < Machine->drv->total_colors;i++)
  38.     {
  39.         int bit0, bit1, bit2, bit3;
  40.  
  41.         bit0 = (*color_prom >> 0) & 0x01; /* intensity */
  42.         bit1 = (*color_prom >> 1) & 0x01; /* red */
  43.         bit2 = (*color_prom >> 2) & 0x01; /* green */
  44.         bit3 = (*color_prom >> 3) & 0x01; /* blue */
  45.  
  46.         /* red component */
  47.         *(palette) = RES_1 * bit1;
  48.         if (bit1) *(palette) += RES_2 * bit0;
  49.         palette++;
  50.         /* green component */
  51.         *(palette) = RES_1 * bit2;
  52.         if (bit2) *(palette) += RES_2 * bit0;
  53.         palette++;
  54.         /* blue component */
  55.         *(palette) = RES_1 * bit3;
  56.         if (bit3) *(palette) += RES_2 * bit0;
  57.         palette++;
  58.  
  59.         color_prom += 4;
  60.     }
  61.  
  62.     for (i = 0;i < 128;i++)
  63.     {
  64.         colortable[i++] = 0;
  65.         colortable[i] = (i/2) + 1;
  66.     }
  67. }
  68.  
  69. /***************************************************************************
  70.  
  71.   Draw the game screen in the given osd_bitmap.
  72.   Do NOT call osd_update_display() from this function, it will be called by
  73.   the main emulation engine.
  74.  
  75. ***************************************************************************/
  76. void tankbatt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  77. {
  78.     int offs;
  79.  
  80.  
  81.     /* for every character in the Video RAM, check if it has been modified */
  82.     /* since last time and update it accordingly. */
  83.     for (offs = videoram_size - 1; offs >= 0; offs--)
  84.     {
  85.         if (dirtybuffer[offs])
  86.         {
  87.             int sx,sy;
  88.  
  89.  
  90.             dirtybuffer[offs] = 0;
  91.  
  92.             sx = offs % 32;
  93.             sy = offs / 32;
  94.  
  95.             drawgfx(tmpbitmap,Machine->gfx[0],
  96.                     videoram[offs],
  97.                     (videoram[offs]) >> 2,
  98.                     0,0,
  99.                     8*sx,8*sy,
  100.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  101.         }
  102.     }
  103.  
  104.     /* copy the temporary bitmap to the screen */
  105.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  106.  
  107.     /* Draw the bullets */
  108.     for (offs = 0;offs < tankbatt_bulletsram_size;offs += 2)
  109.     {
  110.         int x,y;
  111.         int color;
  112.  
  113.  
  114.         color = 63;    /* cyan, same color as the tanks */
  115.  
  116.         x = tankbatt_bulletsram[offs + 1];
  117.         y = 255 - tankbatt_bulletsram[offs] - 2;
  118.  
  119.         drawgfx(bitmap,Machine->gfx[1],
  120.                 0,    /* this is just a square, generated by the hardware */
  121.                 color,
  122.                 0,0,
  123.                 x,y,
  124.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  125.     }
  126.  
  127. }
  128.  
  129.